home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / nwlock.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  20KB  |  663 lines

  1. {$X+,B-,V-} {essential compiler directives}
  2.  
  3. UNIT nwLock;
  4.  
  5. { nwLock unit as of 950301 / NwTP 0.6 API. (c) 1993,1995, R. Spronk
  6.  
  7.   This unit was based on units by
  8.  
  9.    a. Scott A. Lewis, 36 Maythorpe Drive, Windsor, CT 06095, U.S.A.
  10.       Note: (1987) 76515,135@Compuserve.Com
  11.  
  12.    b. Erik van Heyningen, Hague Consulting Group,
  13.       The Hague, the Netherlands.
  14.       Note: (1994) hcg@hacktick.nl    }
  15.  
  16. { Function:                          Interrupt:  Notes:
  17.  
  18.   Physical File locking/unlocking
  19.   -------------------------------
  20.  
  21. * LogPhysicalFile                     EB           (6) -> F203
  22. * LockPhysicalFileSet                 F204
  23. * ReleasePhysicalFile                 EC               -> F205
  24. * ReleasePhysicalFileSet              CD               -> F206
  25. * ClearPhysicalFile                   ED           (6) -> F207
  26. * ClearPhysicalFileSet                CF               -> F208
  27.  
  28.   Logical File Locking
  29.   --------------------
  30.  
  31. + LogLogicalFile                                   (5)
  32. + LogLogicalFileSet                                (5)
  33. + ReleaseLogicalFile                               (5)
  34. + ReleaseLogicalFileSet                            (5)
  35. + ClearLogicalFile                                 (5)
  36. + ClearLogicalFileSet                              (5)
  37.  
  38.   Logical record locking/unlocking
  39.   --------------------------------
  40.  
  41. * LogLogicalRecord                    D0               -> F209
  42. * LockLogicalRecordSet                D1               -> F20A
  43. * ReleaseLogicalRecord                D2               -> F20C
  44. * ReleaseLogicalRecordSet             D3               -> F20D
  45. * ClearLogicalRecord                  D4               -> F20B
  46. * ClearLogicalRecordSet               D5               -> F20E
  47.  
  48.   GetLogicalRecordInformation         F217/F0      (3)
  49.   GetLogicalRecordsByConnection       F217/EF      (3)
  50.  
  51.   Physical record locking/unlocking
  52.   ---------------------------------
  53.  
  54. . LogPhysicalRecord                   BC               -> F21A
  55. . LockPhysicalRecordSet               C2               -> F21B
  56. . ReleasePhysicalRecord               BD               -> F21C
  57. . ReleasePhysicalRecordSet            C3               -> F21D
  58. . ClearPhysicalRecord                 BE               -> F21E
  59. . ClearPhysicalRecordSet              C4               -> F21F
  60.  
  61.   GetPhysRecLocksByConnectionAndFile  F217/ED      (3)
  62.   GetPhysRecLocksByFile               F217/EE      (3)
  63.  
  64. - ControlRecordAccess                 5C (DOS)     (4)
  65.  
  66.  
  67.   Not Implemented
  68.   ---------------
  69.  
  70. - GetLockMode                         C600         (1)
  71. - SetLockMode                         C601         (1)
  72. - BeginLogicalFileLocking             C8  / F201   (2)
  73. - EndLogicalFileLocking               C9  / F202   (2)
  74.  
  75.   Notes: -Semaphores can be found in the nwSema Unit
  76.          (1) Obsolete
  77.          (2) Not supported by (all) 3.x versions
  78.          (3) Supported by NW 3.x and upwards
  79.          (4) Generic physical record locking call, DOS 3.1+
  80.              Equivalent to:
  81.              I . LockPhysicalRecord (without logging)
  82.              II. ReleasePhysicalrecord
  83.          (5) Use the equivalent LogicalRecordLocking calls
  84.              to emulate LogicalFileLocking. NOTE: remember
  85.              that there's only ONE Log.
  86.          (6) Includes VLM fix for filenames (GetTrueEntryName
  87.              in the nwFile unit is called)
  88.          -> F2xx To be rewritten to the F2 interface.
  89. }
  90.  
  91. INTERFACE
  92.  
  93. Uses nwIntr,nwMisc;
  94.  
  95. CONST { Log Resource }
  96.       LD_LOG             = 0;
  97.       LD_LOG_LOCK        = 1; { Deny all access to file/record }
  98.       LD_LOG_LOCK_RO     = 3; { Allow read / deny write (record locking only)}
  99.       { Lock Resource }
  100.       LD_lOCK            = 0; { Deny all access to file/record }
  101.       LD_LOCK_RO         = 1; { Allow read / deny write (record locking only)}
  102.  
  103. Var Result:word;
  104.  
  105. {------------------- PHYSICAL FILE LOCKING OPERATIONS -----------------------}
  106.  
  107. {F204 [2.15c+]}
  108. FUNCTION LockPhysicalFileSet(TimeoutLimit : Word) : Boolean;
  109. {Lock a set of files that were logged by the LogFile function }
  110.  
  111. {CD.. [1.0+]}
  112. FUNCTION ReleasePhysicalFileSet:boolean;
  113. { Release lock on set of files in logged table, files remain logged }
  114.  
  115. {CF   [1.0+]}
  116. FUNCTION ClearPhysicalFileSet : Boolean;
  117. { Unlock and UnLog the entire logged file set }
  118.  
  119. {EB.. [1.0+]}
  120. FUNCTION LogPhysicalFile(FileName : String; LockDirective : Byte; TimeoutLimit : Word) : Boolean;
  121. {Log files for later use }
  122.  
  123. {EC.. [1.0+]}
  124. FUNCTION ReleasePhysicalFile(FileName : String) : boolean;
  125. {Release file lock, but keep logged in the table }
  126.  
  127. {ED.. [1.0+]}
  128. FUNCTION ClearPhysicalFile(FileName : String) : boolean;
  129. {Release a file from the file log table, unlock the file if it is locked }
  130.  
  131. { ------------------- LOGICAL RECORD LOCKING OPERATIONS --------------------}
  132.  
  133. {D0  [1.0+]}
  134. FUNCTION LogLogicalRecord(Name:string; LockDirective:Byte; Timeout: Word) : Boolean;
  135. {Add a record to the lockable logical record table }
  136.  
  137. {D1.. [1.0+]}
  138. FUNCTION LockLogicalRecordSet(LockDirective:Byte; TimeoutLimit : Word) : Boolean;
  139. {Lock all logged records }
  140.  
  141. {D2.. [1.0+]}
  142. FUNCTION ReleaseLogicalRecord(Name : String) : Boolean;
  143. {Unlock a record, keep record in logtable }
  144.  
  145. {D3.. [1.0+]}
  146. FUNCTION ReleaseLogicalRecordSet : Boolean;
  147. {Unlock all locked records, keep records logged }
  148.  
  149. {D4.. [1.0+]}
  150. FUNCTION ClearLogicalRecord(Name : String) : Boolean;
  151. {Unlock and UnLog a record }
  152.  
  153. {D5.. [1.0+]}
  154. FUNCTION ClearLogicalRecordSet : Boolean;
  155. {Unlocks and UnLogs all logged records }
  156.  
  157. {F217/EF [2.1x+]}
  158. Function GetLogicalRecordLocksByConnection(ConnNbr:word;
  159.                                  {i/o} Var NextRecNbr:word;
  160.                                        Var TaskNbr:word;
  161.                                        Var LockStatus:Byte;
  162.                                        Var LockName:String):Boolean;
  163. { You need console operator rights to use this function }
  164.  
  165.  
  166. {----------------------- PHYSICAL RECORD LOCKING OPERATION -----------------}
  167.  
  168. {BC.. [1.0+]}
  169. function LogPhysicalRecord(Handle:Word;
  170.                            LockDirective:Byte;
  171.                            RecordOffset,RecordLength:Longint;
  172.                            TimeOutLimit:Word): boolean;
  173. {Add a record to the lockable physical record logtable }
  174.  
  175. {BD.. [1.0+]}
  176. function ReleasePhysicalRecord( Handle:Word; RecordOffset,RecordLength:Longint) : boolean;
  177. {Unlock record, keep record logged }
  178.  
  179. {BE.. [1.0+]}
  180. function ClearPhysicalRecord(Handle:Word; RecordOffset,RecordLength:Longint): boolean;
  181. {Unlock and Unlog a record }
  182.  
  183. {C2.. [1.0+]}
  184. function LockPhysicalRecordSet(LockDirective: byte; TimeoutLimit : Word): boolean;
  185. {Lock all logged records }
  186.  
  187. {C3.. [1.0+]}
  188. function ReleasePhysicalRecordSet : boolean;
  189. {Unlock all logged records, keep records logged }
  190.  
  191. {C4.. [1.0+]}
  192. function ClearPhysicalRecordSet : boolean;
  193. {Unlocks and unLogs all logged records }
  194.  
  195.  
  196. IMPLEMENTATION{==============================================================}
  197.  
  198. uses nwFile;
  199.  
  200. Var regs:TTRegisters;
  201.  
  202.  
  203. Procedure SetLockMode(mode:Byte);
  204. begin
  205. regs.AH:=$c6;
  206. regs.al:=mode; { 0 or 1 }
  207. RealModeIntr($21,regs);
  208. end;
  209.  
  210. (* THE FOLLOWING PROCEDURES ARE FOR LOGGING AND LOCKING/RELEASING FILE SETS *)
  211. (* File locking by set can be very effective in avoiding deadly embrace *)
  212.  
  213. {F204 [3.x+]}
  214. FUNCTION LockPhysicalFileSet(TimeoutLimit : Word) : Boolean;
  215. Type Treq=record
  216.           _TimeOutLimit:Word;
  217.           end;
  218.      TPreq=^Treq;
  219. BEGIN
  220. With TPreq(GlobalReqBuf)^
  221.  do begin
  222.     _TimeoutLimit:=swap(TimeoutLimit);
  223.     end;
  224. F2SystemCall($04,SizeOf(Treq),0,result);
  225. LockPhysicalFileSet:=(result=0);
  226. { 00 Successful  FF Fail  FE Timeout }
  227. END;
  228.  
  229.  
  230. {CD.. [1.0+]}
  231. FUNCTION ReleasePhysicalFileSet:boolean;
  232. { Release lock on set of files in logged table, files remain logged }
  233. { These files remain open but cannot be accessed without an error }
  234. { To reuse them, send another lock file set }
  235. Type Treq=record
  236.           end;
  237. BEGIN
  238. WITH Regs
  239.   DO BEGIN
  240.      AH := $CD;
  241.      RealModeIntr($21,Regs);
  242.      result:=0;
  243.      END;
  244. ReleasePhysicalFileSet:=true;
  245. END;
  246.  
  247. {CF  [2.0+]}
  248. FUNCTION ClearPhysicalFileSet : Boolean;
  249. { Unlock and UnLog the entire personal file set (all files are closed) }
  250. BEGIN
  251. WITH Regs
  252.   DO BEGIN
  253.      AH := $CF;
  254.      RealModeIntr($21,Regs);
  255.      result:=0;
  256.      END;
  257. ClearPhysicalFileSet:=true;
  258. END;
  259.  
  260.  
  261. {EB.. [2.0+] }
  262. FUNCTION LogPhysicalFile(FileName : String; LockDirective : Byte; TimeoutLimit : Word) : Boolean;
  263. { This function allows a station to log files for later personal use }
  264. { After the desired files are logged, function CBh can be used to lock }
  265. { the entire set of files }
  266. { !! There is a known problem with lock directive 3 (log and lock shareable)
  267.      use 1 instead. }
  268. Type Treq=record
  269.           LockDirective:Byte;
  270.           TimeOutLimit:Word;
  271.           FileName:string[255]; { or Asciiz ? }
  272.           end;
  273. Var temp1,temp2:word;
  274.     TEname:string;
  275. BEGIN
  276. GetTrueEntryName(FileName,TEname); { also UpCases string }
  277. { IF this function isn't included and VLMs are used, this call will
  278.   *appear* to be successful. No error code is returned, the call is
  279.   however unsuccessful. }
  280. WITH Regs
  281.  DO BEGIN
  282.      AH := $EB;
  283.      AL := LockDirective;                  { 0 = Log Only, 1 Log and Lock }
  284.      BP := TimeoutLimit;                   { in 1/18 seconds, 0 = No wait }
  285.      TEname := TEName+#0;           { Terminate with a nul for asciiz }
  286.      Move(TEname[1],GlobalReqBuf^,ord(TEname[0]));
  287.      GetGlobalBufferAddress(DS,DX,temp1,temp2);
  288.      { DS:DX real mode pointer to buffer in realmode-range holding Filename }
  289.      RealModeIntr($21,Regs);
  290.      Result:=AL;
  291.      LogPhysicalFile := (Result = 0);
  292.      END;
  293. { FE Timeout  FF hardware error }
  294. END;
  295.  
  296.  
  297. {EC.. [1.0+]}
  298. FUNCTION ReleasePhysicalFile(FileName : String) : boolean;
  299. { Release file lock, but keep logged in the table }
  300. Var temp1,temp2:word;
  301.     TEname:string;
  302. BEGIN
  303. GetTrueEntryName(FileName,TEname); { also UpCases string }
  304. { IF this function isn't included and VLMs are used, this call will
  305.   *appear* to be successful. No error code is returned, the call is
  306.   however unsuccessful. }
  307. WITH Regs
  308.  DO BEGIN
  309.     AH := $EC;
  310.     UpString(FileName);
  311.     TEName := TEName+#0;                               { null terminate }
  312.     Move(TEname[1],GlobalReqBuf^,ord(TEname[0]));
  313.     GetGlobalBufferAddress(DS,DX,temp1,temp2);
  314.     { DS:DX real mode pointer to buffer in realmode-range holding Filename }
  315.     RealModeIntr($21,Regs);
  316.     result:=AL;
  317.     ReleasePhysicalFile:=(result=0);
  318.     END;
  319. {FF File not found }
  320. END;
  321.  
  322. {ED.. [1.0+]}
  323. FUNCTION ClearPhysicalFile(FileName : String) : boolean;
  324. { Release a file from the file log table, unlock the file if it is locked }
  325. Var temp1,temp2:word;
  326. BEGIN
  327. WITH Regs
  328.  DO BEGIN
  329.     AH := $ED;
  330.     UpString(FileName);
  331.     FileName := FileName+#0;                               { null terminate }
  332.     Move(Filename[1],GlobalReqBuf^,ord(Filename[0]));
  333.     GetGlobalBufferAddress(DS,DX,temp1,temp2);
  334.     { DS:DX real mode pointer to buffer in realmode-range holding Filename }
  335.     RealModeIntr($21,Regs);
  336.     Result:=AL;
  337.     ClearPhysicalFile := (Result = 0);
  338.     { 0 means OK  FF File not found}
  339.   END;
  340. END;
  341.  
  342.  
  343. (* THE FOLLOWING FUNCTIONS ARE FOR LOGICAL LOCKING OPERATIONS *)
  344. (* Logical locks work only if all software accessing the files use the *)
  345. (* same logical synchronization scheme.  Logical locks are much easier *)
  346. (* and faster to implement than physical locks. *)
  347.  
  348.  
  349. {D0  [1.0+]}
  350. FUNCTION LogLogicalRecord(Name:String; LockDirective:Byte; Timeout: Word) : Boolean;
  351. { This function will log the specified record string in the record log table }
  352. { of the requesting station.  }
  353. { Max length of name: 99 chars }
  354. { LockDirective LD_LOG         = 0;
  355.                 LD_LOG_LOCK    = 1;  Deny all access to file/record
  356.                 LD_LOG_LOCK_RO = 3;  Allow read / deny write }
  357. { TimeOut=0 means NoWait }
  358. Var temp1,temp2:word;
  359. BEGIN
  360. WITH Regs
  361.  DO BEGIN
  362.      AH := $D0;
  363.      AL := LockDirective;
  364.      UpString(Name);
  365.      Move(Name,GlobalReqBuf^,ord(Name[0])+1);
  366.      GetGlobalBufferAddress(DS,DX,temp1,temp2);
  367.      { DS:DX real mode pointer to buffer in realmode-range holding Filename }
  368.      BP := Timeout;       { In 1/18th seconds (use only with lock bit set }
  369.      RealModeIntr($21,Regs);
  370.      Result:=AL;
  371.      LogLogicalRecord := (Result=0);
  372.     { FFh  fail }
  373.     { FEh  timeout }
  374.     { 96h  No dynamic memory for file }
  375.     END;
  376. END;
  377.  
  378.  
  379. {D1 [1.0+]}
  380. FUNCTION LockLogicalRecordSet(LockDirective:Byte; TimeoutLimit : Word) : Boolean;
  381. { Call this to lock all records logged with Log_Logical_Record }
  382. { LockDirective LD_LOCK        = 0;  Deny all access to file/record
  383.                 LD_LOCK_RO     = 1;  Allow read / deny write }
  384. BEGIN
  385. WITH Regs
  386. DO BEGIN
  387.      AH := $D1;
  388.      AL := LockDirective;
  389.      BP := TimeoutLimit;                  { In 1/18th seconds, 0 = No wait }
  390.      RealModeIntr($21,Regs);
  391.      Result:=AL;
  392.      LockLogicalRecordSet := (Result=0);
  393.      {00 - Success
  394.       FF - fail,
  395.       FE - timeout }
  396.    END;
  397. END;
  398.  
  399. {D2.. [1.0+]}
  400. FUNCTION ReleaseLogicalRecord(Name : String) : Boolean;
  401. { Call this to release a logical record lock without removing the rec }
  402. { from the table }
  403. Var temp1,temp2:word;
  404. BEGIN
  405. WITH Regs
  406. DO BEGIN
  407.     AH := $D2;
  408.     UpString(Name);
  409.     Move(Name,GlobalReqBuf^,ord(Name[0])+1);
  410.     GetGlobalBufferAddress(DS,DX,temp1,temp2);
  411.     { DS:DX real mode pointer to buffer in realmode-range holding Filename }
  412.     RealModeIntr($21,Regs);
  413.     Result:=AL;
  414.     ReleaseLogicalRecord := (Result=0);
  415.     { FF No record found }
  416.   END;
  417. END;
  418.  
  419. {D3.. [1.0+]}
  420. FUNCTION ReleaseLogicalRecordSet : Boolean;
  421. { release all locked logical records, doesn't remove them from the table }
  422. BEGIN
  423. WITH Regs
  424. DO BEGIN
  425.     AH := $D3;
  426.     RealModeIntr($21,Regs);
  427.     Result:=0;
  428.     ReleaseLogicalRecordSet := True;
  429.    END;
  430. END;
  431.  
  432. {D4.. [1.0+]}
  433. FUNCTION ClearLogicalRecord(Name : String) : Boolean;
  434. { This call unlocks and removes the Logical Record lock from the table }
  435. Var temp1,temp2:word;
  436. BEGIN
  437. WITH Regs
  438. DO BEGIN
  439.     AH := $D4;
  440.     UpString(Name);
  441.     Move(Name,GlobalReqBuf^,ord(Name[0])+1);
  442.     GetGlobalBufferAddress(DS,DX,temp1,temp2);
  443.     { DS:DX real mode pointer to buffer in realmode-range holding Filename }
  444.     RealModeIntr($21,Regs);
  445.     Result:=AL;
  446.     ClearLogicalRecord := (Result=0);
  447.     { FF No record Found }
  448.    END;
  449. END;
  450.  
  451. {D5.. [1.0+]}
  452. FUNCTION ClearLogicalRecordSet : Boolean;
  453. { Unlocks and removes from the table all of the stations logical record locks }
  454. BEGIN
  455. WITH Regs
  456. DO BEGIN
  457.     AH := $D5;
  458.     RealModeIntr($21,Regs);
  459.     Result:=0;
  460.     ClearLogicalRecordSet := True;
  461.   END;
  462. END;
  463.  
  464.  
  465. (************* THE FOLLOWING ARE PHYSICAL RECORD LOCK CALLS ****************)
  466.  
  467. {F:BC..:Lock (& Log) records in a file}
  468. function LogPhysicalRecord(Handle:Word;
  469.                            LockDirective:Byte;
  470.                            RecordOffset,RecordLength:Longint;
  471.                            TimeOutLimit:Word): boolean;
  472. { Max length of name: 99 chars }
  473. { LockDirective LD_LOG         = 0;
  474.                 LD_LOG_LOCK    = 1;  Deny all access to file/record
  475.                 LD_LOG_LOCK_RO = 3;  Allow read / deny write }
  476. { TimeOut=0 means NoWait; TimeOut not valid if logging only }
  477. { Handle is the file handle }
  478. begin
  479. with regs
  480. do begin
  481.     AH := $BC;
  482.     AL := LockDirective;
  483.     BX := Handle;
  484.     CX := HiLong(RecordOffset);
  485.     DX := LowLong(RecordOffset);
  486.     BP := TimeOutLimit;
  487.     SI := HiLong(RecordLength);
  488.     DI := LowLong(RecordLength);
  489.     RealModeIntr($21,Regs);
  490.     Result:=AL;
  491.     LogPhysicalRecord := (Result=0);
  492.     { $FF = fail, $FE Timeout, $96 = No dynamic memory }
  493.   end;
  494. end;
  495.  
  496. {BD.. [1.0+]}
  497. function ReleasePhysicalRecord( Handle:Word; RecordOffset,RecordLength:Longint) : boolean;
  498. { When a record is released, it is unlocked for use by someone else, but }
  499. { it remains in the log table }
  500. { Handle is the file handle, Start_Hi and Start_Lo are the boundaries of }
  501. { the locked region to be released }
  502. begin
  503. with regs
  504. do begin
  505.     AH := $BD;
  506.     BX := Handle;
  507.     CX := HiLong(RecordOffset);
  508.     DX := LowLong(RecordOffset);
  509.     SI := HiLong(RecordLength);
  510.     DI := LowLong(RecordLength);
  511.     RealModeIntr($21,Regs);
  512.     Result:=AL;
  513.     ReleasePhysicalRecord := (Result=0);
  514.     { $FF = No locked record found}
  515.    end;
  516. end;
  517.  
  518. {BE.. [1.0+]}
  519. function ClearPhysicalRecord(Handle: Word;
  520.                              RecordOffset,RecordLength:Longint): boolean;
  521. { Handle is the file handle, Start_Hi and Start_Lo are the boundaries }
  522. { of the file region to be locked. Clearing a record will unlock it }
  523. { and remove it from the log table. }
  524. begin
  525. with regs
  526. do begin
  527.     AH := $BE;
  528.     BX := Handle;
  529.     CX := HiLong(RecordOffset);
  530.     DX := LowLong(RecordOffset);
  531.     SI := HiLong(RecordLength);
  532.     DI := LowLong(RecordLength);
  533.     RealModeIntr($21,Regs);
  534.     Result:=AL;
  535.     ClearPhysicalRecord := (Result=0);
  536.     { $FF No locked record found }
  537.    end;
  538. end;
  539.  
  540. {C2.. [1.0+]}
  541. function LockPhysicalRecordSet(LockDirective: byte; TimeoutLimit: Word): boolean;
  542. { flgs are the lock flags:  bit 1 set means shared (non-exclusive) lock }
  543. { Timeout is in 1/18 seconds, 0 = no wait, -1 means indefinite wait }
  544. { This function attempts to lock all of the records logged in the station's }
  545. { log table. }
  546. { LockDirective LD_LOCK        = 0;  Deny all access to file/record
  547.                 LD_LOCK_RO     = 1;  Allow read / deny write }
  548. { !! There is known problem when the locking directive equals 1. }
  549. begin
  550. with regs
  551. do begin
  552.     AH := $C2;
  553.     AL := LockDirective;
  554.     BP := TimeOutLimit;
  555.     RealModeIntr($21,Regs);
  556.     Result:=AL;
  557.     LockPhysicalRecordSet := (Result=0);
  558.     { $FF = fail, $FE = timeout fail }
  559.    end;
  560. end;
  561.  
  562. {C3.. [1.0+]}
  563. function ReleasePhysicalRecordSet : boolean;
  564. { unlocks the entire record log table of the station.  records remain in }
  565. { the log table. }
  566. begin
  567.  regs.AH := $C3;
  568.  RealModeIntr($21,Regs);
  569.  Result:=0;
  570.  ReleasePhysicalRecordSet := True;
  571. end;
  572.  
  573. {C4.. [1.0+]}
  574. function ClearPhysicalRecordSet : boolean;
  575. { unlocks and removes from the log table any records logged and locked }
  576. begin
  577.  regs.AH := $C4;
  578.  RealModeIntr($21,Regs);
  579.  Result:=0;
  580.  ClearPhysicalRecordSet := True;
  581. end;
  582.  
  583.  
  584. {F217/EF [2.1x+]}
  585. Function GetLogicalRecordLocksByConnection(ConnNbr:word;
  586.                                  {i/o} Var NextRecNbr:word;
  587.                                        Var TaskNbr:word;
  588.                                        Var LockStatus:Byte;
  589.                                        Var LockName:String):Boolean;
  590. { You need console operator rights to use this function }
  591. Type Treq=record
  592.           len         :Word;
  593.           subFunc     :Byte;
  594.           _ConnNbr    :word; {lo-hi} { !! Invalid numbers may cause an abend }
  595.           _LastRecSeen:word; {lo-hi}
  596.           end;
  597.      Trep=record
  598.           _LastRecSeen :word; {lo-hi}
  599.           _NbrOfRecords:word; {lo-hi}
  600.           _LockInfo    :array[1..508] of byte;
  601.           end;
  602.      TPreq=^Treq;
  603.      TPrep=^Trep;
  604. Begin
  605. WITH TPreq(GlobalReqBuf)^
  606.  do begin
  607.     subFunc:=$EF;
  608.     _ConnNbr:=ConnNbr;
  609.     _LastRecSeen:=NextRecNbr;
  610.     len:=SizeOf(Treq)-2;
  611.     end;
  612. F2SystemCall($17,SizeOf(Treq),SizeOf(Trep),result);
  613. With TPrep(GlobalReplyBuf)^
  614.  do begin
  615.     Move(_LastRecSeen,NextRecNbr,2);
  616.  
  617.  
  618.     end;
  619. GetLogicalRecordLocksByConnection:=(result=0)
  620. { Valid completion codes:
  621.   $00 Success
  622.   $FF Failure
  623. }
  624. end;
  625.  
  626. {$IFDEF xxxx}
  627.  
  628. {F217/ [2.1x+]}
  629. Function (   ):Boolean;
  630. Type Treq=record
  631.           len:Word;
  632.           subFunc:Byte;
  633.  
  634.           end;
  635.      Trep=record
  636.  
  637.           end;
  638.      TPreq=^Treq;
  639.      TPrep=^Trep;
  640. Begin
  641. WITH TPreq(GlobalReqBuf)^
  642.  do begin
  643.     subFunc:=$
  644.  
  645.     len:=SizeOf(Treq)-2;
  646.     end;
  647. F2SystemCall($17,SizeOf(Treq),SizeOf(Trep),result);
  648. With TPrep(GlobalReplyBuf)^
  649.  do begin
  650.  
  651.     end;
  652.   :=(result=0)
  653. { Valid completion codes:
  654.   $00 Success
  655.   $FF Failure.
  656. }
  657. end;
  658.  
  659. {$ENDIF}
  660.  
  661. Begin
  662. SetLockMode(1);
  663. END.